package com.study.springdemo0.controller;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/springdemo")
@Tag(name = "SpringDemo")
public class SpringAIDemo {
    @Autowired
    private OpenAiChatModel chatModel;

    @Autowired
    private OllamaChatModel ollamaChatModel;

    @GetMapping("/hello")
    public String hello(@RequestParam(value = "message", defaultValue = "hello")
                        String message) {
        String result = ollamaChatModel.call(message);
        System.out.println(result);
        return  result;
    }
}
